(function($, window, document, undefined) {
  
  /* 轮播图 */
  new Swiper('.focus > .swiper-container', {
    autoplay: {
      disableOnInteraction: false
    },
    on: {
      init: function() {
        var that = this

        $('.focus-pagination-item').on('click', function(e) {
          e.preventDefault()
          
          var $el = $(e.target)

          if (!$el.is('.focus-pagination-item')) {
            $el = $el.parents('.focus-pagination-item')
          }

          $el
            .addClass('active')
            .siblings()
            .removeClass('active')

          that.slideTo($el.index())

        })

      },
      slideChange: function() {
        $('.focus-pagination-item')
          .eq(this.activeIndex)
          .addClass('active')
          .siblings()
          .removeClass('active')
      }
    }
  })
  /* / 轮播图 */
  
  /* 游戏推荐 */
  new Swiper('.hot-game > .swiper-container', {
    allowTouchMove: false,
    navigation: {
      nextEl: '.hot-game > .swiper-container .swiper-button-next',
      prevEl: '.hot-game > .swiper-container .swiper-button-prev',
    },
    on: {
      init: function() {
        var that = this

        $('.j-hot-game-tab .news-title-tab-item').on('click', function(e) {
          e.preventDefault()
          
          var $el = $(e.target)

          if (!$el.is('.news-title-tab-item')) {
            $el = $el.parents('.news-title-tab-item')
          }

          $el
            .addClass('active')
            .siblings()
            .removeClass('active')

          that.slideTo($el.index())

        })

      },
      slideChange: function() {
        $('.j-hot-game-tab .news-title-tab-item')
          .eq(this.activeIndex)
          .addClass('active')
          .siblings()
          .removeClass('active')
      }
    }
  });
  /* /游戏推荐 */
  
  /* 奖池 */
  (function() {
    
    var $digit = $('#jackpot-digit')
    
    // 初始化数字
    var digit = 411265932.59

    var timer,
        // 间隔
        interval = 100,
        // 最大随机数 0-max,注意包括后面两位小数，所以需要乘以100
        max      = 10 * 100

    timer = setInterval(timerHandler, interval)

    function timerHandler() {
      $digit.text(digit.toMoney())
      
      // 这里做数字改动
      // 这里随机加了一个数
      digit += _.random(max) / 100
    }

  })();
  /* /奖池 */

})(jQuery, window, document)